<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../include.jsp"%>


<div class="modal-header">
   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
   <h4 class="modal-title" id="layoutModalLabel"><strong>新增用户信息</strong></h4>
</div>
<div class="modal-body">
  <form method="post" class="form-horizontal" action="${ctx }/admin/admin/dictionary/type/${method}">
        			<div class="form-group">
        				 <label class="col-sm-2 control-label" for="dtypeKey">属性key</label>
        				 <div class="col-sm-10 ">
        					<input type="text" class="form-control" id="dtypeKey"  name="dtypeKey" placeholder="属性key">
        				 </div>
        			</div>
        			<div class="form-group">
        				 <label class="col-sm-2 control-label" for="dtypeLabel">属性描述</label>
        				 <div class="col-sm-10 ">
        					<input type="text" class="form-control" id="dtypeLabel"  name="dtypeLabel" placeholder="属性描述">
        				 </div>
        			</div>
 </form>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  <button type="button" class="btn btn-primary" id="submitForm">提交</button>
</div>
<script>

$(function(){
	

	$('.form-horizontal').validate({
	    errorElement : 'span',
	    errorClass : 'help-block',
	    focusInvalid : false,
	    rules : {
					dtypeKey:{maxlength:[20],required:true},
					dtypeLabel:{maxlength:[20],required:true},
					status:{maxlength:[4],required:true},
					version:{maxlength:[11],required:true},
					creator:{maxlength:[20],required:true},
					creatime:{required:true},
					updator:{maxlength:[20],required:true},
					updatetime:{required:true}
	    },
	    messages : {
					dtypeKey:{maxlength:'输入长度最多是20的字符串(汉字算一个字符).',required:'该项为必填项.'},
					dtypeLabel:{maxlength:'输入长度最多是20的字符串(汉字算一个字符).',required:'该项为必填项.'},
					status:{maxlength:'输入长度最多是4的字符串(汉字算一个字符).',required:'该项为必填项.'},
					version:{maxlength:'输入长度最多是11的字符串(汉字算一个字符).',required:'该项为必填项.'},
					creator:{maxlength:'输入长度最多是20的字符串(汉字算一个字符).',required:'该项为必填项.'},
					creatime:{required:'该项为必填项.'},
					updator:{maxlength:'输入长度最多是20的字符串(汉字算一个字符).',required:'该项为必填项.'},
					updatetime:{required:'该项为必填项.'}
	    },
	
	    highlight : function(element) {
	        $(element).closest('.form-group').addClass('has-error');
	    },
	
	    success : function(label) {
	        label.closest('.form-group').removeClass('has-error');
	        label.remove();
	    },
	
	    errorPlacement : function(error, element) {
	        element.parent('div').append(error);
	    }
	});
	
	
	$('#submitForm').on('click' ,function(){
		$submit = $(this) ;
		
		var valid = true ;
		XHZ.formPost('.form-horizontal',$submit ,valid ,function(data){
			var msg = "添加成功" ;
			$('#layoutModal').modal('hide') ;
			if(data.code != 1){
				$('.actionBar .glyphicon-refresh').click() ;
			}else{
				msg = data.message ;
			}
			$submit.removeClass('disabled') ;
			$('#alertModal .modal-body').html(msg) ;
			$('#alertModal').modal({
				backdrop: 'static' ,
				show: true
			}) ;
		}) ;
	}) ;
	

	


});

</script>